package com.ruoyi.web.controller.ring;

import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.enums.TimeUnitEnums;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.ring.domain.dto.RingSleepDetailInfoDTO;
import com.ruoyi.ring.domain.dto.RingSleepDetailListDTO;
import com.ruoyi.ring.domain.dto.SleepInfoDTO;
import com.ruoyi.ring.domain.vo.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ring.domain.RingSleepDetail;
import com.ruoyi.ring.service.IRingSleepDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 睡眠详情
 * 
 * @author liuwp
 * @date 2025-08-18
 */
@RestController
@RequestMapping("/ring/ring_sleep_detail")
public class RingSleepDetailController extends BaseController
{
    @Resource
    private IRingSleepDetailService ringSleepDetailService;

    /**
     * 查询睡眠详情列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_sleep_detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(RingSleepDetail ringSleepDetail)
    {
        startPage();
        List<RingSleepDetail> list = ringSleepDetailService.selectRingSleepDetailList(ringSleepDetail);
        return getDataTable(list);
    }

    /**
     * 导出睡眠详情列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_sleep_detail:export')")
    @Log(title = "睡眠详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RingSleepDetail ringSleepDetail)
    {
        List<RingSleepDetail> list = ringSleepDetailService.selectRingSleepDetailList(ringSleepDetail);
        ExcelUtil<RingSleepDetail> util = new ExcelUtil<RingSleepDetail>(RingSleepDetail.class);
        util.exportExcel(response, list, "睡眠详情数据");
    }

    /**
     * 获取睡眠详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_sleep_detail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ringSleepDetailService.selectRingSleepDetailById(id));
    }

    /**
     * 新增睡眠详情
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_sleep_detail:add')")
    @Log(title = "睡眠详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RingSleepDetail ringSleepDetail)
    {
        return toAjax(ringSleepDetailService.insertRingSleepDetail(ringSleepDetail));
    }
    /**
     * 修改睡眠详情
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_sleep_detail:edit')")
    @Log(title = "睡眠详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RingSleepDetail ringSleepDetail)
    {
        return toAjax(ringSleepDetailService.updateRingSleepDetail(ringSleepDetail));
    }

    /**
     * 删除睡眠详情
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_sleep_detail:remove')")
    @Log(title = "睡眠详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ringSleepDetailService.deleteRingSleepDetailByIds(ids));
    }

}
